home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 4 / Engine / Input.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-01  |  1.6 KB  |  46 lines

  1. //-----------------------------------------------------------------------------
  2. // A wrapper class for handling input via DirectInput. Both the keyboard and
  3. // mouse devices are supported through this class.
  4. //
  5. // Programming a Multiplayer First Person Shooter in DirectX
  6. // Copyright (c) 2004 Vaughan Young
  7. //-----------------------------------------------------------------------------
  8. #ifndef INPUT_H
  9. #define INPUT_H
  10.  
  11. //-----------------------------------------------------------------------------
  12. // Input Class
  13. //-----------------------------------------------------------------------------
  14. class Input
  15. {
  16. public:
  17.     Input( HWND window );
  18.     virtual ~Input();
  19.  
  20.     void Update();
  21.  
  22.     bool GetKeyPress( char key, bool ignorePressStamp = false );
  23.  
  24.     bool GetButtonPress( char button, bool ignorePressStamp = false );
  25.     long GetPosX();
  26.     long GetPosY();
  27.     long GetDeltaX();
  28.     long GetDeltaY();
  29.     long GetDeltaWheel();
  30.  
  31. private:
  32.     HWND m_window; // Handle of the parent window.
  33.     IDirectInput8 *m_di; // DirectInput object.
  34.     unsigned long m_pressStamp; // Current press stamp (incremented every frame).
  35.  
  36.     IDirectInputDevice8 *m_keyboard; // DirectInput keyboard device.
  37.     char m_keyState[256]; // Stores the state of the keyboard keys.
  38.     unsigned long m_keyPressStamp[256]; // Stamps the last frame each key was preseed.
  39.  
  40.     IDirectInputDevice8 *m_mouse; // DirectInput mouse device.
  41.     DIMOUSESTATE m_mouseState; // Stores the state of the mouse buttons.
  42.     unsigned long m_buttonPressStamp[3]; // Stamps the last frame each button was preseed.
  43.     POINT m_position; // Stores the position of the mouse cursor on the screen.
  44. };
  45.  
  46. #endif